package com.axend.aerosense.common.adapter;

import android.content.res.Resources;
import android.view.View;


import com.axend.aerosense.common.R;
import com.axend.aerosense.base.impl.IBaseContentItem;
import com.axend.aerosense.common.databinding.CommonContentSelectItemBinding;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;

import org.jetbrains.annotations.NotNull;


public class ContentSelecteListAdapter extends BaseQuickAdapter<IBaseContentItem , BaseDataBindingHolder<CommonContentSelectItemBinding>> {

    public ContentSelecteListAdapter() {
        super(R.layout.common_content_select_item);
    }

    @Override
    protected void convert(@NotNull BaseDataBindingHolder<CommonContentSelectItemBinding> baseViewHolder, IBaseContentItem bean) {
        if(null == bean){
            return;
        }
        Resources resources = baseViewHolder.itemView.getContext().getResources();
        CommonContentSelectItemBinding itemBinding = baseViewHolder.getDataBinding();
        itemBinding.commonContent.setText(bean.getContent());
        if(bean.isSelected()){
            itemBinding.commonItemSelect.setVisibility(View.VISIBLE);
            itemBinding.commonContent.setTextColor(resources.getColor(R.color.common_item_selector, null));
        }else{
            itemBinding.commonItemSelect.setVisibility(View.GONE);
            itemBinding.commonContent.setTextColor(resources.getColor(R.color.base_text_color_black, null));
        }

    }
}
